<?php
require_once 'application/library/db/gcBasicDao.php';
require_once 'application/constant/dbConstant.php';
/**
 * 网站信息Dao
 * dao_T_AD_M_MEMBERDao
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/05/13
 */

class dao_T_AD_M_SITE_INFODao extends gcBasicDao {
    protected $_table = "T_AD_M_SITE_INFO";

    public function pbGetSiteInfo($strType) {
        $sql = " SELECT "
        			  . " INFO_NO,"
        			  . " INFO_TYPE,"
        			  . " TITLE,"
        			  . " MODIFY_DATE,"
        			  . " CONTENT "
        	   . " FROM "
        	          . " T_AD_M_SITE_INFO "
        	  . " WHERE "
        	  		  . " INFO_TYPE = :InfoType";
        $arrParameter = array("InfoType" => $strType);
        if ($strType == "4") {
            $arrResult = $this->select($sql, $arrParameter, dbReturnType::ALL);
        } else {
            $arrResult = $this->select($sql, $arrParameter, dbReturnType::ROW);
        }
        return $arrResult;
    }

    public function pbUpdateSiteInfo($strType, $strContent) {
        $sql = " UPDATE  T_AD_M_SITE_INFO SET "
        			  . " CONTENT = :Content "
        	  . " WHERE "
        	  		  . " INFO_TYPE = :InfoType";
        $arrParameter = array("InfoType" => $strType, "Content" => $strContent);
        return $this->update($sql, $arrParameter);
    }
    
    public function pbGetNews($strNewsNo) {
        $sql = " SELECT "
        			  . " TITLE,"
        			  . " CONTENT,"
        			  . " MODIFY_DATE "
               . " FROM "
                      . " T_AD_M_SITE_INFO "
              . " WHERE "
              		  . " INFO_TYPE = '4' "
                . " AND "
                      . " INFO_NO = '" . $strNewsNo . "'";
        $strResult = $this->select($sql, null, dbReturnType::ROW);
        return $strResult;
    }
    
    public function pbSaveNews($arrParameter) {
        $sql = " UPDATE T_AD_M_SITE_INFO "
        						 . " SET "
        						    . " TITLE   = :Title,"
        						    . " CONTENT = :Content "
        						. " WHERE "
        						    . "INFO_TYPE = '4' "
        						    . " AND INFO_NO = :InfoNo ";
        return $this->update($sql, $arrParameter);
        						    
    }
    
    public function pbAddNews($arrParameter) {
        $sql = " INSERT INTO T_AD_M_SITE_INFO "
        					. " (TITLE,"
        					. " INFO_TYPE,"
        					. " MODIFY_DATE,"
        					. " CONTENT )"
        				. " VALUES("
        				    . " :Title,"
        				    . " '4',"
        				    . " NOW(),"
        				    . " :Content)";
        $this->insert($sql, $arrParameter);
    }
    
    public function pbDeleteNews($strInfoNo) {
        $sql = " DELETE FROM T_AD_M_SITE_INFO "
        				. " WHERE " 
        				     ." INFO_NO = :InfoNo  "
        				     ."AND INFO_TYPE='4'";
        				     $arrParameter = array("InfoNo" => $strInfoNo);
        $this->delete($sql, $arrParameter);
    }
}